| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkWinUi::ComponentManager Class Referencefinal

Manages the components within nkWinUi. More...

Inheritance diagram for nkWinUi::ComponentManager:

## Public Member Functions
System * | getSystem () const
Component * | createOrRetrieve (nkMemory::StringView name, COMPONENT_TYPE componentType)
Component * | record (nkMemory::StringView name, nkMemory::UniquePtr< Component > resource)
Component * | get (nkMemory::StringView name) const
Component * | getByIndex (unsigned int index) const
void | rename (nkMemory::StringView currentName, nkMemory::StringView newName)
void | erase (nkMemory::StringView name)
nkMemory::UniquePtr< Component > | relinquish (nkMemory::StringView name)

## Detailed Description

Manages the components within nkWinUi.

Responsible for creating and book-keeping them. At all time, the manager is responsible for the memory allocated inside it.

## Member Function Documentation

## ◆ getSystem()

System* nkWinUi::ComponentManager::getSystem | ( |  | ) | const

Returns
  The system the manager is living in.

## ◆ createOrRetrieve()

Component* nkWinUi::ComponentManager::createOrRetrieve | ( | nkMemory::StringView | name,
|  | COMPONENT_TYPE | componentType
| ) |  |

Creates (if unavailable) or retrieves (if available) component attached to passed name.

Parameters

  name | The name, aka identifier, of the component to create or retrieve.
  componentType | The type the component should be.

Returns
  The component attached to passed name, of type requested. The Manager is the owner of the memory returned.

Remarks
  It is possible to cast the component to the type requested if required.

## ◆ record()

Component* nkWinUi::ComponentManager::record | ( | nkMemory::StringView | name,
|  | nkMemory::UniquePtr< Component > | resource
| ) |  |

Records an already existing resource in the manager, passing its ownership around.

Parameters

  name | The name under which the resource should be recorded.
  resource | The resource to record.

Returns
  A raw pointer over the resource, now recorded in the manager.

## ◆ get()

Component* nkWinUi::ComponentManager::get | ( | nkMemory::StringView | name | ) | const

Returns a component attached to a name, if available.

Parameters

  name | The name of the component that should be retrieved.

Returns
  The component if existing, nullptr else.

## ◆ getByIndex()

Component* nkWinUi::ComponentManager::getByIndex | ( | unsigned int | index | ) | const

Returns the component at given index, if available.

Parameters

  index | The index of the component to retrieve.

Returns
  The component attached to given index.

Remarks
  An index refers to the index in the manager's container, so one index can be attached through different components depending on allocations. This method is meant to loop on all components in one go, because of this.

## ◆ rename()

void nkWinUi::ComponentManager::rename | ( | nkMemory::StringView | currentName,
|  | nkMemory::StringView | newName
| ) |  |

Renames a component.

Parameters

  currentName | The name of the component to rename.
  newName | The name to reassign to the component.

## ◆ erase()

void nkWinUi::ComponentManager::erase | ( | nkMemory::StringView | name | ) |

Erases a component. Memory attached to it will be freed.

Parameters

  name | The name identifying the component to erase.

## ◆ relinquish()

nkMemory::UniquePtr<Component> nkWinUi::ComponentManager::relinquish | ( | nkMemory::StringView | name | ) |

Requests the manager to relinquish the ownership of a resource and pass it around.

Parameters

  name | The name of the recorded resource to relinquish.

Returns
  The ownership over the resource requested if available, nullptr otherwise.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsWinUi/Components/ComponentManager.h